module namespace meta="http://sendmeafilter.com/common/meta";
import module namespace security="http://sendmeafilter.com/common/security" at "security.xqy";

declare boundary-space preserve;
declare option xdmp:mapping "false";

declare function meta:prefer($one,$two) { if(fn:exists($one)) then $one else $two };
declare function meta:create($name,$default,$meta) {
	<meta name="{$name}" content="{meta:prefer(fn:data($meta[@name=$name]/@value),$default)}"/>
};
declare function meta:option($name,$meta) { fn:data(($meta[@name=$name]/@value)[1]) }; 

declare function meta:meta($meta) {	
(
	<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>,
	<meta charset="utf-8"/>,
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>,
    
    meta:create("description", "sendmeafilter, home filters, home filter, furnace filter, premium filters, filter shipment, filters shipped, air filter, home air, air purifier, home maintenance, furnace, furnace maintenance, allergies, asthma, allergy control, asthma control, allergy treatment, allergy treatment", $meta),
	meta:create("keywords", "home, sendmeafilter, home filter, clean air", $meta),
	meta:create("generator", "GetSimple", $meta),
	meta:create("viewport", "width=device-width, initial-scale=1.0", $meta),
	meta:create("robots", "index, follow", $meta),
	meta:create("generator", "GetSimple", $meta),

	<link rel="stylesheet" href="/assets/css/reset.css"/>,
	<link rel="stylesheet/less" type="text/css" href="/assets/css/{if(fn:starts-with(xdmp:get-request-url(),'/backoffice')) then 'back' else ''}style.less"/>,
	<link rel="xstylesheet" media="screen" href="/assets/css/formwizard.css"/>,
	<link rel="xstylesheet" media="screen" href="/assets/css/template.css"/>,	
	<link rel="canonical" href="http://sendmeafilter.com{fn:tokenize(xdmp:get-original-url(),'\?')[1]}"/>,
	<!-- link rel="stylesheet" href="uniform.default.css" type="text/css" media="screen" charset="utf-8" / -->,

	<xscript src="/assets/js/require.js" data-main="assets/js/main"></xscript>,	
	<script src="/assets/js/handle.js" type="text/javascript">&nbsp;</script>,
	<script src="/assets/js/jquery-1.js" type="text/javascript">&nbsp;</script>,
	<script src="/assets/js/jquery-ui-1.js" type="text/javascript">&nbsp;</script>,	
	<script src="/assets/js/jquery.js" type="text/javascript">&nbsp;</script>,
	<script src="/assets/js/home.js" type="text/javascript">&nbsp;</script>,
	<script src="/assets/js/kart.js" type="text/javascript">&nbsp;</script>,	
	<script src="/assets/js/smaf.js" type="text/javascript">&nbsp;</script>,	
	if(meta:option('ckeditor',$meta) = 'true') then <script type="text/javascript" src="assets/ckeditor/ckeditor.js">&nbsp;</script> else (),
	<script src="/assets/js/less.js" type="text/javascript">&nbsp;</script>,
	if(fn:false()) then <script src="jquery.uniform.js" type="text/javascript">&nbsp;</script> else (),

	
	<!--[if lt IE 9]>
		<script src="//html5shiv.googlecode.com/svn/trunk/html5.js">&nbsp;</script>
	<![endif]--> ,
	
	<!--[if lt IE 7 ]>
	    <script src="http://sendmeafilter.com/theme/SendMeAFilter/assets/js/dd_belatedpng.js">&nbsp;</script>
	    <script> DD_belatedPNG.fix('img, .png_bg'); //fix any <img> or .png_bg background-image </script>
 	<![endif]-->
)

};